home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / BPL70N16 / UCASE437.ASM < prev    next >
Assembly Source File  |  1994-08-29  |  3KB  |  59 lines

  1.  
  2. ; *******************************************************
  3. ; *                                                     *
  4. ; *     Turbo Pascal Runtime Library Version 7.0        *
  5. ; *     Character Handling Routines                     *
  6. ; *                                                     *
  7. ; *     Copyright (C) 1991-94 Norbert Juffa             *
  8. ; *                                                     *
  9. ; *******************************************************
  10.  
  11.              TITLE   UCASE437
  12.  
  13.  
  14. CODE         SEGMENT BYTE PUBLIC
  15.  
  16.              ASSUME  CS:CODE
  17.  
  18. ; Publics
  19.  
  20.              PUBLIC  UpCase437
  21.  
  22. ;-------------------------------------------------------------------------------
  23. ; Enhanced UpCase function: UpCase437 (Ch: CHAR): CHAR
  24. ;
  25. ; UpCase437 translates all characters which have an upper case equivalent in
  26. ; the IBM character set, codepage 437, to upper case.
  27. ;
  28. ; On entry:  [SP+4]  input character
  29. ;
  30. ; On exit:   AL      input character converted to upper case
  31. ;-------------------------------------------------------------------------------
  32.  
  33. UpCase437    PROC    FAR
  34.              MOV     BX, SP            ; new frame pointer
  35.              MOV     AL, SS:[BX+4]     ; get character
  36.              CMP     AL, 'a'           ; char smaller than 'a' ?
  37.              JB      $no_trans         ; yes, no translation
  38.              CMP     AL, 'z'           ; char bigger than 'z' ?
  39.              JA      $special          ; yes, maybe one of the special chars
  40.              SUB     AL, 'a'-'A'       ; translate lower case to upper case
  41. $no_trans:   RET     2                 ; pop parameter and return
  42. $special:    CLD                       ; auto increment for string instructions
  43.              MOV     DI, OFFSET Tbl1   ; address of table with special chars
  44.              MOV     CX, Len           ; length of that table
  45.              MOV     BX, CS            ; initialize extra segment
  46.              MOV     ES, BX            ;  (table in code segment)
  47.              REPNE   SCASB             ; character translatable ?
  48.              JNE     $not_found        ; no, not in table
  49.              MOV     AL, ES:[DI+Len-1] ; yes, load upper case char
  50. $not_found:  RET     2                 ; pop parameters and return
  51. Tbl1         DB      'äüöåæéñç'        ; translatable lower case chars
  52. Tbl2         DB      'ÄÜÖÅÆÉÑÇ'        ; and their upper case versions
  53. Len          EQU     Tbl2-Tbl1         ; compute table length
  54. UpCase437    ENDP
  55.  
  56. CODE         ENDS
  57.  
  58.              END
  59.